package game.logic;

/**
 * This class represents a cup. It is concerned with the state of all of the cups on the board.
 * @author Justin
 *
 */
public class Cup 
{
	/**
	 * The light color that is currently being displayed by a cup.
	 * @author Justin
	 *
	 */
	public enum LightColor
	{
		RED,
		GREEN;
	}
	
	/**
	 *  The current color of the light.  In general, green equals not hit, while red is hit. 
	 */
	private LightColor color;
	
	/**
	 * Constructor.
	 * @param color - the initial color of this cup.
	 */
	public Cup(LightColor color)
	{
		this.color = color;
	}
	
	/**
	 * Determines if this cup is "on" or "off".  Generally a player wins
	 * when all cups are "off".
	 * @return - true if the cup is red, false otherwise
	 */
	public boolean isOff()
	{
		boolean retVal;
		if(color == LightColor.RED)
		{
			retVal = true;
		}
		else
		{
			retVal = false;
		}
		
		return retVal;
	}
	
	/**
	 * Turns the light "off".
	 */
	public void turnOff()
	{
		if(color == LightColor.RED)
		{
			return;
		}
		color = LightColor.RED;
	}
	
	/**
	 * Turns the light "on".  
	 */
	public void turnOn()
	{
		if(color == LightColor.GREEN)
		{
			return;
		}
		color = LightColor.GREEN;
	}
	
	/**
	 * Toggles the color of the light between red and green.
	 */
	public void toggleLight()
	{
		if(color == LightColor.RED)
		{
			turnOn();
		}
		else
		{
			turnOff();
		}
	}

	/**
	 * Gets the current color of the light.
	 * @return - the current light color.
	 */
	public LightColor getColor() 
	{
		return color;
	}
}
